package com.demo.manager.util;

import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @BelongsProject: manager
 * @BelongsPackage: com.demo.manager.config
 * @Author: LiuJiayin
 * @Date: 2021/3/25 16:21
 * @Description: TODO
 */
public class Md5Util {
    public static String getMd5Result(String password) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
        messageDigest.update(password.getBytes("UTF-8"));
        byte[] s = messageDigest.digest();
        String result="";
        for (int i = 0;i<s.length;i++){
            result+=Integer.toHexString((0x000000ff & s[i]) | 0xffffff00).substring(6);
        }
        return result;
    }
}
